@extends('../manage.layout')
@section('content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            内容管理
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
            <li class="active">Here</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- general form elements -->
                <form id="form">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        {{--<a href="javascript:batchdelAll()"><span class="btn btn-danger">批量删除</span></a>--}}
                        <span style="margin-left: 30px"><i class="fa fa-users"></i> 已有<span style="color:#f00">{{ $total }}</span>名客户进行了品牌顾问咨询</span>
                    </div>
                    <!-- table start -->
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <h3 class="box-title">留言列表</h3>

                                    <div class="box-tools">
                                        {{-- <div class="input-group input-group-sm" style="width: 150px;">
                                             <input type="text" name="table_search" class="form-control pull-right" placeholder="Search">

                                             <div class="input-group-btn">
                                                 <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                                             </div>
                                         </div>--}}
                                    </div>
                                </div>
                                <!-- /.box-header -->
                                <div class="box-body table-responsive no-padding">
                                    <table class="table table-hover">
                                        <tr>
                                            {{--<th><input type="checkbox" value="" onclick="All(this)"></th>--}}
                                            <th>ID</th>
                                            <th>名称</th>
                                            <th>创建时间</th>
                                            <th>公司名称</th>
                                            <th>电话</th>
                                            <th>需求项目</th>
                                            <th>留言内容</th>
                                            {{--<th>操作</th>--}}
                                        </tr>
                                        <script>
                                            function All(obj) {
                                                $("table input[type='checkbox']").prop('checked', $(obj).prop('checked'));
                                            }
                                        </script>
                                        @foreach($list as $value)
                                            <tr>
                                                {{--<td><input name="chkbox[]" type="checkbox" value="{{ $value->id }}"></td>--}}
                                                <td>{{ $value->id }}</td>
                                                <td>{{ $value->name }}</td>
                                                <td>{{ $value->create_time }}</td>
                                                <td>{{ $value->company }}</td>
                                                <td>{{ $value->phone }}</td>
                                                <td>
                                                    @foreach($field as $k=>$v)
                                                        @if($value->project == $v['id'])
                                                        {{ $v['project'] }}
                                                        @endif
                                                    @endforeach
                                                </td>
                                                <td>{{ $value->content }}</td>
                                                {{--<td><a href="javascript:delSubscribe({{ $value->id }})"><span class="label label-danger">删除</span></a></td>--}}
                                            </tr>
                                        @endforeach
                                    </table>
                                </div>
                                <!-- /.box-body -->
                            </div>
                            <!-- /.box -->
                        </div>
                        <div style="text-align: center">{{ $list->links() }}</div>
                    </div>
                    <!-- /.table -->
                </div>
                </form>
            </div>
        </div>
    </section>
    <!-- /.content -->
@endsection
@section('script')
@endsection
<script>
    function delSubscribe(id) {
        layer.confirm('删除不可恢复，是否继续？', {
            btn:['确定','取消'] //按钮
        }, function() {
            $.post("{{ url('manage/message/') }}/"+id,{'_method':'delete','_token':"{{ csrf_token() }}"},function(data){
                if(data.status==0) {
                    layer.msg(data.msg, {time:1500, icon:5});
                } else {
                    layer.msg(data.msg, {time:1500, icon:6});
                    window.location.href = "/manage/message/";
                }
            });
        }, function() {

        });
    }
    function batchdelAll() {
        layer.confirm('删除不可恢复，是否继续？', {
            btn:['确定','取消'] //按钮
        }, function() {
            $.ajax({
                url: "/manage/messbatcdel/",
                type: "GET",
                data: $('#form').serialize(),
                success: function (data) {
                    layer.msg(data.msg, {time:1500, icon:6, end:function(){location.reload();}});
                },
                error: function (data) {
                    layer.msg(data.msg, {time:1500, icon:6, end:function(){location.reload();}});

                }
            });
        });
    }
</script>